<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
 <!DOCTYPE html>
<html>

<head>
	<base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <title>网站列表</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="static/templet/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="static/templet/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="static/templet/css/animate.min.css" rel="stylesheet">
    <link href="static/templet/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="static/templet/js/plugins/kindeditor/themes/default/default.css" />
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
    <form action="newStation/list" method="post" id="keyWordForm">
        <div class="row">    
        <!-- 检索 -->
        	<div class="col-sm-12">
        		<table class="table table-hover">
        			<tr>
        				<td>
							 <input type="text" value="${param.userName}" name="userName" placeholder="请输入用户名" class="form-control">
        				</td>
        				<td>
							 <input type="text" value="${param.domain}" name="domain" placeholder="请输入域名" class="form-control">
        				</td>
        				<td>
							<select class="form-control" name="state" id="state" data-placeholder="网站状态">
					            <option value="">全部状态</option>
					            <option value="01" <c:if test="${param.state == '01'}">selected</c:if>>已启用</option>
					            <option value="02" <c:if test="${param.state == '02'}">selected</c:if>>已停用</option>
					        </select>
        				</td>
        				<td> 
        					<select class="form-control" name="vender" id="vender" data-placeholder="服务器机组" style="vertical-align:top;">
					            <option value="">全部</option>
					           <%--  <option value="-1" <c:if test="${param.vender == '-1'}">selected</c:if>>未处理</option> --%>
					            <c:forEach items="${venderList}" var="vender">
					            	<option value="${vender.id }" <c:if test="${param.vender == vender.id}">selected</c:if>>${vender.venderName }</option>
					            </c:forEach>
					        </select>
        				</td>
        				<td>
        					<span style="float:right;"><input type="button" class="btn btn-primary" onclick="searchs();" value="检索"/></span>
        				</td>
        			</tr>
        		</table>
			</div>
            <div class="col-sm-12">
            	
                <div class="ibox float-e-margins">
                <a class="btn btn-primary " href="javascript:add();" target="_self">新增</a>
                    <div class="ibox-content">
                        <table class="table table-hover" id="keyWordTable">
                            <thead>
                                <tr>
                                    <th class="text-center">ID</th>
                                    <th class="text-center">用户</th>
                                    <th class="text-center">域名类型</th>
                                    <th class="text-center">域名</th>
                                    <th class="text-center">创建时间</th>
                                    <th class="text-center">服务器机组</th>
                                    <th class="text-center">网站信息</th>
                                    <th class="text-center">状态</th>
                                    <th class="text-center">操作</th>
                                </tr>
                            </thead>
                            <tbody>
							<c:forEach items="${page.list}" var="key" varStatus="vs">
                            	<tr class="text-center">
                                    <td>${key.id }</td>
                                    <c:choose>
                                    <c:when test="${key.userName == '' || key.userName == null}">
                                    <td>-</td>
                                    </c:when>
                                     <c:otherwise>
        								<td>${key.userName }</td>
    								 </c:otherwise>
    								 </c:choose>
									<td>${key.domainType }</td>
									<td><a  href="javascript:SeeKeywords('${key.id }');" title="关键词列表">${key.domain }</a></td>
									<td>${key.create_time }</td>
									<td>${key.venderName }</td>
									<td>${key.remark }</td>
									
								   <c:choose>
                                    <c:when test="${key.state == '01'}">
                                  		<td>已启用</td>
                                  		<td>
                                  			<a href="javascript:SeeKeywords('${key.id}');" title="关键词">关键词</a>
                                  			<a href="javascript:addKeywords('${key.id}','${key.domain }','${key.userName }','${key.venderName }');" title="关键词">添加关键词</a>
											<a href="javascript:updateState('${key.id}','02');" title="上架">停用</a>
                                  		</td>
                                    </c:when>
                                     <c:otherwise>
        								<td>已停用</td>
        								<td>
        									<a href="javascript:SeeKeywords('${key.id}');" title="关键词">关键词</a>
        									<a href="javascript:update('${key.id}');" title="编辑">编辑</a>
											<a href="javascript:updateState('${key.id}','01');" title="上架">启用</a>
											<a href="javascript:deteleDomian('${key.id}');" title="删除">删除</a>
        								</td>
    								 </c:otherwise>
   								 </c:choose>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/page.jsp">
                        	<jsp:param value="keyWordForm" name="form"/>
                        </jsp:include>
                    </div>
                </div>
            </div>
        </div>
      </form>
    </div>
    <script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
    <script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="static/templet/js/file_upload.js"></script>
    <script src="static/templet/js/plugins/kindeditor/kindeditor-all-min.js"></script>
    <script src="static/templet/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="static/templet/js/plugins/layer/layer.min.js"></script>
    <script src="static/templet/js/iframe.min.js"></script>
    <script src="static/templet/js/plugins/layer/laydate/laydate.js"></script>
    <script type="text/javascript">
    
    $(function(){
    	var message = '${param.messages1}';
		if(message != null && message != "") {
			parent.layer.msg('保存成功', {icon: 1});
		}
    })
    
    
    function searchs(){
    	$("#keyWordForm").submit();
    }
    
    
    //新增
    function add(){
    	parent.layer.open({
    	    type: 2,
    	    title: '新增网站',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['60%', '80%'],
    	    content: 'newStation/domain/toAdd',
    	    cancel:function(index, layero){
    	    	iframe.get(layero);
    	    	if(result == 1){
    	    		location.reload(true);
    	    	}
    	    }
    	});
    }
    
    //新增关键词
    function addKeywords(domainId,domain,userName,venderName){
    	parent.layer.open({
    	    type: 2,
    	    title: '新增网站关键词',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['60%', '80%'],
    	    content: 'newStation/domain/toKeywordsAdd?domainId='+domainId+'&domain='+domain+'&userName='+userName+'&venderName='+venderName,
    	    cancel:function(index, layero){
    	    	iframe.get(layero);
    	    	if(result == 1){
    	    		location.reload(true);
    	    	}
    	    }
    	});
    }
    
    //编辑
    function update(id){
    	parent.layer.open({
    	    type: 2,
    	    title: '修改网站',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['60%', '80%'],
    	    content: 'newStation/domain/toEdit?id='+id,
    	    cancel:function(index, layero){
    	    	iframe.get(layero);
    	    	if(result == 1){
    	    		location.reload(true);
    	    	}
    	    }
    	});
    }
    
   
    //批量修改
	function updateState(id, state) {
		var msg = state == '01' ? '启用' : '停用';
		parent.layer.confirm('确定要'+msg+'此网站吗', {
		    btn: ['确定','取消'], //按钮
		    shade: false //不显示遮罩
		}, function(){
			   var url = "newStation/updateDomainState.do?state=" + state + "&id=" + id;
                $.get(url, function (data) {
                	var result = data.result;
                    if (result.state == 1) {
                    	parent.layer.msg('修改完成', {icon: 1});
                    	location.reload();
                    } else {
                    	parent.layer.msg(result.message, {icon: 2});
                    }
                }); 
		}, function(){});
	}
	
    
	function deleteInfo(id) {
		parent.layer.confirm('确定要删除此资讯吗？', {
		    btn: ['确定','取消'], //按钮
		    shade: false //不显示遮罩
		}, function(){
			   var url = "info/deleteInfo.do?infoId=" + id;
                $.get(url, function (data) {
                	var result = data.result;
                	 if (result.state == 1) {
                     	parent.layer.msg('删除完成', {icon: 1});
                     	location.reload();
                     } else {
                     	parent.layer.msg(result.message, {icon: 2});
                     }
                }); 
		}, function(){});
	}
	
    
    
    function checkOrCancelAll(){
		//1.获取checkbo的元素对象
		var chElt=document.getElementById("checked_all");
		//2.获取选中状态
		var checkedElt=chElt.checked;
		//3.若checked=true,将所有的复选框选中,checked=false,将所有的复选框取消
		var allCheck=document.getElementsByName("ids");
		//4.循环遍历取出每一个复选框中的元素
		var mySpan=document.getElementById("choose");
		if(checkedElt){
			//全选
			for(var i=0;i<allCheck.length;i++){
				//设置复选框的选中状态
				allCheck[i].checked=true;
			}
			mySpan.innerHTML="取消全选";
		}else{
			//取消全选
			for(var i=0;i<allCheck.length;i++){
				allCheck[i].checked=false;
			}
			mySpan.innerHTML="全选";
		}
	}
 
    function talk(msg){
	    parent.layer.open({
	        type: 1,
	        skin: 'layui-layer-rim', //加上边框
	        area: ['620px', '340px'], //宽高
	        content: msg
	    });
    }

    //新站关键词列表
    function SeeKeywords(domainId){
    	parent.layer.open({
    	    type: 2,
    	    title: '网站关键词列表',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['85%', '95%'],
    	    content: 'newStation/keyWordlist?domainId='+domainId,
    	    cancel:function(index, layero){
    	    	iframe.get(layero);
    	    	if(result == 1){
    	    		location.reload(true);
    	    	}
    	    }
    	});
    }
	var start={elem:"#startTime",format:"YYYY-MM-DD",min:"1970-01-01",max:"2099-06-16 23:59:59",istime:true,istoday:false,choose:function(datas){end.min=datas;end.start=datas}};var end={elem:"#endTime",format:"YYYY-MM-DD",min:"1970-01-01",max:"2099-06-16 23:59:59",istime:true,istoday:false,choose:function(datas){start.max=datas}};laydate(start);laydate(end);
    </script>

	</body>

</html>